/* $Id: room.hpp jjs $ */
/*
   Copyright (C) 2007 by Jurjen Stellingwerff <jurjen@stwerff.xs4all.nl>
   Part of the Moros Project http://moros.sourceforge.net/

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License.
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY.

   See the COPYING file for more details.
*/
#ifndef __ROOM_H
#define __ROOM_H

#include <map>

enum member_status {
	Status_none,
	Status_muted,   ///< Member that is only allowed to listen
	Status_member,  ///< Normal talking member of the room
	Status_moderator, ///< Member that can moderate other members and appoint moderators
	Status_leader   ///< Special moderator that can unmoderate others
 };

/// Different types of channels:

enum room_type {
    Room_open,      ///< anybody can join and gain speach
    Room_invitation, ///< people joining can only read and need to gain speech after that
    Room_private    ///< people cannot join or see the room they need to be invited for that
 };


/// Structure with login information of a member into a channel
class room_member {
	public:
	/// Information of the member
	class member *mem;
	/// The current status in this room
	int status;
	/// The login time of this user
	int time;

	room_member() {
		mem=NULL;
		status=Status_none;
		time=0;
	}
};

/// Information on the status of a chat room

class room {
	public:
	/// Name of the room, written before each line in the world chat box
	std::string name;
	/// Longer name in the channel list and on top of a seperate channel box
	std::string description;
	int type;
	/// Only moderators can talk in this room state
	bool silenced;
	/// The creator of the channel
	///
	/// Can be someone that is appointed as new leader by the current one
	/// When the leader leaves the room the moderator with the longest login becomes leader
	class member *leader;
	/// Set of people in the channel with their login time mapped with their alias
	std::map<std::string, room_member> members;

	room(std::string roomname="") {
		name = roomname;
		description = "";
		type = Room_open;
		silenced = false;
	}

	string state() {
		switch(type) {
			case Room_open:
				if (silenced) return "silenced";
				return "open";
		}
		return "INVITATION";
	}
};

#endif // __ROOM_H
